<extend name="Public:base" />
<block name="content">
    <script type="text/javascript" src="Common/js/My97DatePicker/WdatePicker.js"></script>
    <style type="text/css">
		.popuping{
			z-index: 1050;
			width: auto;
			padding: 10px;
			margin-right: auto;
			margin-left: auto;

		}
		.bootbox.fade .popuping{
			-webkit-transform: translate(0,-25%);
			-ms-transform: translate(0,-25%);
			transform: translate(0,-25%);
			-webkit-transition: -webkit-transform .3s ease-out;
			-moz-transition: -moz-transform .3s ease-out;
			-o-transition: -o-transform .3s ease-out;
			transition: transform .3s ease-out;
		}
		.bootbox.in .popuping{
			-webkit-transform: translate(0,0);
			-ms-transform: translate(0,0);
			transform: translate(0,0);
		}
		.bootbox.in .popuping-content{
			position: relative;
			background-color: #fff;
			border: 1px solid #999;
			border: 1px solid rgba(0,0,0,0.2);
			border-radius: 6px;
			outline: 0;
			-webkit-box-shadow: 0 3px 9px rgba(0,0,0,0.5);
			box-shadow: 0 3px 9px rgba(0,0,0,0.5);
			background-clip: padding-box;
			padding: 20px;
			margin: 100px auto 0;
		}
    </style>
	<div><button id="add" class="btn btn-xs btn-info radius5 marginB10" >添加回访记录</button>
	<a href="{:U('Comment/Warning&role=master')}" class="btn btn-xs btn-info radius5 marginB10" >返回</a></div>
		<div class="table-responsive">
			<table class="table table-striped table-bordered table-hover" id="nav-table">
				<thead>
					<tr>
						<th>回访时间</th>
						<th>回访人</th>
						<th>回访记录</th>
						<th>处理结果</th>
					</tr>
				</thead>
				<tbody>
						<volist name="advise" id="vo">
							<input type="hidden" name="advise_id" value="{$vo.advise_id}"/>
							<input type="hidden" name="role" value="{:I('advise_id_user')}"/>
 						<tr>
							<td>{$vo.add_time}</td>
							<td>{$vo.visitor}</td>
							<td>{$vo.record}</td>
							<td>{$vo.result}</td>
						</tr>
						</volist>
						<!--<tr>-->
							<!--<td colspan="20" class="page">{$page}</td>-->
						<!--</tr>-->
				</tbody>
			</table>
		</div>

	<div class="bootbox modal fade">
		<div class="popuping">
			<div class="popuping-content" style="width: 450px;">
				<div class="ui-jqdialog-content ui-widget-content" id="editcntgrid-table">
					<div>
						<form name="FormPost" id="FrmGrid_grid-table" class="FormGrid" onsubmit="return false;" style="width:auto;overflow:auto;position:relative;height:auto;">
							<table id="TblGrid_grid-table" class="EditTable" cellspacing="0" cellpadding="0" border="0">
								<tbody>
								<tr id="FormError" style="display:none">
									<td class="ui-state-error" colspan="2"></td>
								</tr>
								<tr style="display:none" class="tinfo">
									<td class="topinfo" colspan="2"></td>
								</tr>
								<tr rowpos="1" class="FormData" id="tr_id">
									<td class="CaptionTD">回访人</td>
									<td class="DataTD">&nbsp;
										<input style="width: 300px" type="text" id="id" name="visitor" role="textbox" class="FormElement ui-widget-content ui-corner-all">
									</td>
								</tr>
								<tr rowpos="2" class="FormData" id="tr_sdate">
									<td class="CaptionTD">回访记录</td>
									<td class="DataTD">&nbsp;
										<input style="width: 300px" type="text" id="sdate" name="record" role="textbox" class="FormElement ui-widget-content ui-corner-all">
									</td>
								</tr>
								<tr rowpos="2" class="FormData" id="tr_sdate">
									<td class="CaptionTD">处理结果</td>
									<td class="DataTD">&nbsp;
										<input type="radio"  name="result" value="1"/>继续回访
										<input type="radio" name="result" value="2"  />处理完毕
									</td>
								</tr>
								</tbody>
							</table>
						</form>
						<div style="text-align: center;">
							<button class="btn btn-xs btn-info radius5 marginT10" id="save">保存</button>
							<button class="btn btn-xs btn-info radius5 marginT10" style="margin-left: 100px;" id="cancel">取消</button>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

</block>
<block name="javascript">
<script>
$(function(){

	$("#search").click(function () {
        var url = $(this).attr('url');
        var query = $('.search-form').find('input,select').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
        query = query.replace(/^&/g, '');
        if (url.indexOf('?') > 0) {
            url += '&' + query;
        } else {
            url += '?' + query;
        }
        window.location.href = url;
    });

});
	$('#add').click(function(){
		$("body").append("<div class=\"modal-backdrop fade in\"></div>");
		$(".bootbox.modal.fade").addClass("in").show(400);
	});

	$('#cancel').click(function(){
		$(".bootbox.modal.fade").addClass("in").hide(400);
		setTimeout(function(){
			$(".modal-backdrop.fade.in").remove()
		},200);
	});

	$('#save').click(function(){
        var advise_id = $("input[name='advise_id']").val();
        var advise_id_user = $("input[name='role']").val();
        var visitor = $.trim($("input[name='visitor']").val());
        var record = $.trim($("input[name='record']").val());
        var result = $.trim($("input[name='result']:checked").val());

        if(visitor==''||record==''||result==''){
            $.jbox.info('请输入信息！','提示');
            return false;
        }

		$.ajax({
			url:"{:U('Comment/addReturnVisit')}",
            type:"post",
			data:{
				advise_id : advise_id,
				advise_id_user : advise_id_user,
				visitor : visitor,
				result : result,
				record : record
			},
			success:function(data){
				if(data=='1'){
                    $.jbox.tip("添加成功！", 'loading');
                    window.setTimeout(function () {window.location.reload() }, 500);
                }else{
                    $.jbox.info("添加失败！",'提示');
                }
			}
		});
	});
</script>
</block>